/*
 * Параллельные рёбра
 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <limits.h>
#include <ctype.h>

/* {{{ autoarray */
struct vector {
	int *data;
	int n;
	int max;
};

void
vector_init(struct vector *v, int p)
{
	if (p < 0)
		p = 0;
	v->max = 1 << p;
	v->n = 0;
	v->data = calloc((size_t) v->max, sizeof *v->data);
}

int
vector_append(struct vector *v, int a)
{
	int *t;

	if (v->max == 0)
		vector_init(v, 0);

	if (v->n + 1 > v->max) {
		t = realloc(v->data, sizeof *t * (v->max *= 2));
		if (!t) {
			fprintf(stderr, "vector_append(): failed to allocate %d bytes\n", v->max);
			return 1;
		} else {
			v->data = t;
		}
	}

	v->data[v->n++] = a;

	return 0;
}

int
vector_sort(struct vector *v, int (*cmpf)(const void *, const void *))
{
	if (v->max > 0 && v->n > 1) {
		qsort(v->data, (size_t) v->n, sizeof *v->data, cmpf);
		return 0;
	} else {
		return 1;
	}
}

int
vector_cleanup(struct vector *v)
{
	if (v->max > 0) {
		v->max = v->n = 0;
		free(v->data);
		v->data = NULL;
		return 0;
	} else {
		return 1;
	}
}
/* }}} */

struct adjlist {
	struct vector adj_v;
	int s;
};

void
adjl_connect(struct adjlist *node, int conid)
{
#ifdef D2_FPARAM
	fprintf(stderr, "adjl_connect(node=%p = { adj_v = { data=%p, n=%d, max=%d } , s=%d}, conid=%d)\n",
			node, node->adj_v.data, node->adj_v.n, node->adj_v.max, node->s, conid);
#endif
	if (node->adj_v.max == 0)
		vector_init(&node->adj_v, 1);
	vector_append(&node->adj_v, conid);
}

void
adjl_cleanup(struct adjlist *node)
{
	if (node->adj_v.max != 0) {
		free(node->adj_v.data);
		node->adj_v.n = node->adj_v.max = 0;
	}
}

int
numcmp(const void *p1, const void *p2)
{
	return * (const int *) p1 - * (const int *) p2;
}

#ifdef D3
void
debug_test21(struct adjlist *al, int n)
{
	register int r1, r2;

	for (r1 = 0; r1 < n; r1++) {
		fprintf(stderr, "%d\t", r1 + 1);
		for (r2 = 0; r2 < al[r1].adj_v.n; r2++) {
			fprintf(stderr, "%d ", al[r1].adj_v.data[r2] + 1);
		}
		fputc('\n', stderr);
	}
}
#endif

int
main(int argc, char **argv)
{
	struct adjlist *al;
	int i, n, m, j, a, b;

	scanf("%d%d", &n, &m);
	al = calloc(n, sizeof *al);
	for (i = 0; i < m; i++) {
		scanf("%d%d", &a, &b);
		--a; --b;
		adjl_connect(&al[a], b);
		adjl_connect(&al[b], a);
	}

	for (i = 0; i < n; i++) {
		vector_sort(&al[i].adj_v, numcmp);
	}
#ifdef D3
	debug_test21(al, n);
#endif
	for (i = 0; i < n; i++) {
		for (j = 1; j < al[i].adj_v.n; j++) {
			if (al[i].adj_v.data[j - 1] == al[i].adj_v.data[j] &&
					i != al[i].adj_v.data[j]) {
				fputs("YES\n", stdout);
#ifdef D3
				fprintf(stderr, "i = %d\n", i + 1);
#endif
				goto out;
			}
		}
	}
	fputs("NO\n", stdout);

out:
	for (i = 0; i < n; i++)
		adjl_cleanup(&al[i]);
	free(al);
	return 0;
}
